function setItem(key,value){
    // 对象、数组的类型都是 object
    if (typeof value === 'object') value = JSON.stringify(value);
    window.localStorage.setItem(key, value);
}

function getItem(key) {
    const data = window.localStorage.getItem(key);
    try {
        return JSON.parse(data)
    } catch (err) {
        return data
    }
}

function removeItem(key){
    window.localStorage.removeItem(key);
}

function clear(){
    window.localStorage.clear();
}